package com.mtsmda.chapter3.arrayEx;

public class ArrayPr {
	
	static int kkk;
	static Integer integer;
	
	public static void main(String[] args) {
		
		int [] k = new int[]{15 ,19, 250, 05, 152};
		int [][] kk = new int[3][];
		kk[0] = k;
		kk[1] = new int[17];
		kk[2] = new int [11];
		
		for(int i = 0;i < kk.length; i++){
			for(int j = 0; j < kk[i].length; j++){
				if(kk[i][j] == 0){
					kk[i][j] = (int)(Math.random() * 100);
				}
			}
		}
		
		for(int i = 0;i < kk.length; i++){
			for(int j = 0; j < kk[i].length; j++){
				System.out.print(kk[i][j] + "  ");
			}
			System.out.println("\n");
		}
		
		System.out.println("**************");
		int countElementsInArray = 0;
		double sumElementsInArray = 0.0;
		double d[][] = new double[][]{{159.25, 357.25}, {326.15, 742.25, 159542, 12}};
		double maxValue = d[0][0];
		String maxValueIndex = "0";
		double minValue = maxValue;
		String minValueIndex = "0";
		for(int i = 0; i < d.length; i++){
			for(int j = 0; j < d[i].length; j++){
				System.out.print(d[i][j] + " ");
				countElementsInArray++;
				sumElementsInArray += d[i][j];
				if(maxValue < d[i][j]){
					maxValue = d[i][j];
					maxValueIndex = i + " X " + j;
				}
				
				if(minValue > d[i][j]){
					minValue = d[i][j];
					minValueIndex = i + " X " + j;
				}
			}
			System.out.println("\n");
		}
		System.out.println("count Elements In Array - " + countElementsInArray);
		System.out.println("sum Elements In Array - " + sumElementsInArray);
		System.out.println("avegare Elements In Array - " + (sumElementsInArray / countElementsInArray));
		System.out.println("max value Elements In Array - " + maxValue);
		System.out.println("min value Elements In Array - " + minValue);
		System.out.println("sum max and min elementov - " + (maxValue + minValue));
		System.out.println("average max and min elementov - " + ((maxValue + minValue) / 2));
		System.out.println("max value index - " + maxValueIndex);
		System.out.println("min value index - " + minValueIndex);
		
		takesAnArray(new int[]{15, 19,125, 1253, 1473});
		
		System.out.println("*************");
		int [] ar = new int[5]; 
		byte b = -128;
		short s = 32400;
		char c = 'g';
		ar[0] = b;
		ar[1] = s;
		ar[2] = c;
		for(int i : ar){
			System.out.println(i + " ");
		}
		
		System.out.println("\n*************\n");
		
		Car [] cars = new Car[]{new Car(), new Subaru(), new Ferrari()};
		for(Car car : cars){
			car.getColor();
		}
		
		ModelCarI [] modelCarIs = cars;
		for(ModelCarI modelCarI : modelCarIs){
			modelCarI.getCarModel(null);
		}
		
		Subaru [] subarus = new Subaru[]{new Subaru()};
		subarus[0].getCarModel("");
		int [] cv  = new int[]{15, 185, 142, 5436, 123456};
		int [][]  cv2 = new int[2][];
		cv2[0] = cv;
		cv2[1] = new int[]{2};
	}
	
	private static void takesAnArray(int [] ar){
		for(int i : ar){
			System.out.print(i + "  ");
		}
		System.out.println();
	}
	
}